@import '@/assets/styles/var.less';

.products-page {
  min-height: 100vh;
  background-color: #f5f5f5;

  .products-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 44px;
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;

    .header-left {
      display: flex;
      align-items: center;
      cursor: pointer;
      padding: 8px;
      margin-left: -8px;
      border-radius: 4px;
      transition: background-color 0.2s;

      &:active {
        background-color: #f0f0f0;
      }

      .nut-icon {
        font-size: 20px;
        color: #333;
      }
    }

    .header-title {
      font-size: 18px;
      font-weight: 600;
      color: #333;
    }

    .header-right {
      width: 36px;
    }
  }

  .products-content {
    .products-tabs {
      height: 100%;

      .nut-tabs__titles {
        background: #fff;
        border-bottom: 1px solid #e5e5e5;
        position: sticky;
        top: 44px;
        z-index: 10;
      }

      .nut-tabs__content {
        height: calc(100% - 44px);
        overflow-y: auto;
        padding: 16px;
      }
    }
  }

  .loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;

    .loading-text {
      margin-top: 12px;
      font-size: 14px;
      color: #999;
    }
  }

  .empty-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;

    .empty-text {
      font-size: 14px;
      color: #999;
    }
  }

  .product-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;

    .product-item {
      background: #fff;
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      transition: transform 0.2s, box-shadow 0.2s;

      &:active {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
      }

      .product-image {
        width: 100%;
        height: 120px;
        overflow: hidden;
        position: relative;

        .nut-image {
          width: 100%;
          height: 100%;
        }

        .product-tag {
          position: absolute;
          top: 8px;
          left: 8px;
          background: rgba(7, 193, 96, 0.9);
          color: white;
          font-size: 10px;
          padding: 2px 6px;
          border-radius: 4px;
          font-weight: 500;
          backdrop-filter: blur(4px);
          -webkit-backdrop-filter: blur(4px);
          max-width: 60px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }

      .product-info {
        padding: 12px;

        .product-name {
          font-size: 14px;
          font-weight: 600;
          color: #333;
          margin-bottom: 4px;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          overflow: hidden;
          line-height: 1.4;
        }

        .product-desc {
          font-size: 12px;
          color: #666;
          margin-bottom: 8px;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          overflow: hidden;
          line-height: 1.4;
          text-overflow: ellipsis;
          word-break: break-word;
          max-height: 2.8em; 
        }

        .product-price {
          display: flex;
          align-items: center;
          gap: 8px;
          margin-bottom: 12px;

          .price {
            font-size: 16px;
            font-weight: 700;
            color: #ff6b35;
          }

          .original-price {
            font-size: 12px;
            color: #999;
            text-decoration: line-through;
          }
        }

        .add-cart-btn {
          width: 100%;
          height: 32px;
          font-size: 12px;
          border-radius: 16px;

          .nut-icon {
            font-size: 14px;
            margin-right: 4px;
          }
        }
      }
    }
  }
}

@media (max-width: 375px) {
  .products-page {
    .products-header {
      height: 40px;
      padding: 0 12px;

      .header-title {
        font-size: 16px;
      }
    }

    .products-content {

      .products-tabs {
        .nut-tabs__titles {
          top: 40px;
        }

        .nut-tabs__content {
          height: calc(100% - 40px);
          padding: 12px;
        }
      }
    }

    .product-list {
      gap: 8px;

      .product-item {
        .product-image {
          height: 100px;
        }

        .product-info {
          padding: 10px;

          .product-name {
            font-size: 13px;
          }

          .product-desc {
            font-size: 11px;
          }

          .product-price {
            .price {
              font-size: 15px;
            }
          }

          .add-cart-btn {
            height: 28px;
            font-size: 11px;
          }
        }
      }
    }
  }
}

@media (max-width: 320px) {
  .products-page {
    .product-list {
      grid-template-columns: 1fr;
      gap: 8px;

      .product-item {
        .product-image {
          height: 120px;
        }

        .product-info {
          padding: 12px;

          .product-name {
            font-size: 14px;
          }

          .product-desc {
            font-size: 12px;
          }

          .add-cart-btn {
            height: 32px;
            font-size: 12px;
          }
        }
      }
    }
  }
}
